/**
 * 新增品种
 * 胡琼
 * 2017/8/21
 **/
var testConfig = require('../testConfig');
const ipcRenderer = require('electron').ipcRenderer;
var l = parseInt(window.sessionStorage.getItem("runTimes"));
var planData = JSON.parse(window.sessionStorage.getItem('planData'));
var caseData =  planData.cases[l];
var msg = {
    reportId:planData.reportId,
    taskId:planData.taskId,
    caseId:caseData.caseId,
    caseNumber:caseData.caseNumber,
    isOver:'false'
};
function TestProject() {
    this.init = function () {
        var arr = [];
        arr.push(this.step1,
            this.step2,
            this.step3,
            this.step4,
            this.step5,
            this.step6,
            this.step7,
            this.step8,
            this.step9,
            this.step10,
            this.step11);
        testConfig.testFun.runStep(arr);
    };
    this.step1 = function () {
        $("#aside-nav").find("div.coords").eq(5).find("a")[0].click();
        $("#collapse6").find("li:nth-child(4) .second_lv_li")[0].click();
        msg.stepResult = {
            byname:"skipBreedSet",
            realData:$("#contentIframe iframe").attr('src')
        };
        ipcRenderer.sendToHost(JSON.stringify(msg));
    };
    this.step2 = function () {
        testConfig.testFun.ai().find('#addType')[0].click();
        msg.stepResult = {
            byname:"addBreedPop",
            realData:testConfig.testFun.bi().find("#layer_addform3")
        };
        ipcRenderer.sendToHost(JSON.stringify(msg));
    };
    this.step4 = function () {
        testConfig.testFun.bi().find("input[data-name='name']").val('测试品种3');
    };
    this.step5 = function () {
        testConfig.testFun.bi().find("#selects_1").attr({'my-name':'建筑材料'}).html("<option value='1' selected>建筑材料</option>");
    };
    this.step6 = function () {
        var _html=`<select id="selects_2" index="2">
              <option value="2">金属材料</option>
            </select>`;
        testConfig.testFun.bi().find("#selects_1").after(_html);
    };
    this.step7 = function () {
        testConfig.testFun.bi().find("input[data-name='unit']").val('吨');
    };
    this.step8 = function () {
        testConfig.testFun.bi().find("#img_idtop").attr('src', 'http://choosefine-uat.oss-cn-hangzhou.aliyuncs.com/shopping/user/20170802152959aj8GFGdDEf.jpg');
    };
    this.step9 = function () {
        testConfig.testFun.bi().find('#saveBtn')[0].click();
    };
    this.step10 = function () {
        testConfig.testFun.ai().find("input[data-name='name']").val('测试品种3');
    };
    this.step11 = function () {
        testConfig.testFun.ai().find('#search')[0].click();
    };
}
function testStart() {
    var test = new TestProject();
    test.init();
}
exports.start = testStart;